<?php
require_once "shipping.php";
$Shipping = new Shipping();

require_once "weixin_info.php";//å¾®ä¿¡æŽˆæƒèŽ·å–ç”¨æˆ·å¤´åƒç­‰ä¿¡æ?
require_once "config.php";
$order_sql = $mysql->query("select * from dyspw_goods_order where shop_id=".$_SESSION['Member_info'][0]['id'].  " and state >= 1 ORDER BY time DESC");//è§†é¢‘
$order = $order_sql->fetch_all(MYSQLI_ASSOC);
$waimai_sql = $mysql->query("select * from dyspw_shop_waimai where uid=".$_SESSION['Member_info'][0]['id']);//è§†é¢‘
$waimai = $waimai_sql->fetch_all(MYSQLI_ASSOC);
$param = array(
    'shop_id'   => 11,
    'status'   => 0,
    'offset'   => 0,
    'count'   => 50,
);

$match_list = $Shipping->GetMaiYaTianData('/order/query/',$param);
// print_r($match_list);exit;

foreach ($order as $key => $val) {
    $goods_sql = $mysql->query("select * from dyspw_goods where id=".$val['goods_id']);//è§†é¢‘
    $goods = $goods_sql->fetch_all(MYSQLI_ASSOC);
    $order[$key]['title'] = $goods[0]['title'];
    $order[$key]['details'] = $goods[0]['details'];
    // $order[$key]['money'] = $goods[0]['money'];
    $order[$key]['img'] = $goods[0]['img'];
}
// print_r($order);exit;
 ?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>商户订单</title>
    <script src="js/mui.min.js"></script>
    <link href="css/mui.min.css" rel="stylesheet" />
    <link href="css/orderList.css" rel="stylesheet" />
    <script src="js/layer/layer.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8">
      mui.init()
    </script>
  <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cb5d49b07e0a753dc8ee27ba2c73495d";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>
</head>

  <body>
    <div class="container">
      <div class="navbar">
        <div class="backBtn">
          <span class="mui-icon mui-icon-arrowleft" onclick="javascript:history.back(-1);"></span>
        </div>
        <span>商户订单</span>
      </div>

      <div class="tab">
        <div class="itemTab active">全部 <?php echo count($order); ?></div>
        <!-- <div class="itemTab">已完成11</div>
        <div class="itemTab">未完成11</div> -->
      </div>
      <?php foreach ($order as $key => $val): ?>
          <div class="orderList listAcvtive">
              <div class="itemOrder">
                  <div class="title"><?php echo $val['u_name'] ?></div>
                  <div class="itemDetail">
                      <div class="itemImg">
                          <img src="<?php echo $val['img'] ?>" alt="" />
                      </div>
                      <div class="itemInfo">
                          <div class="price"><?php echo $val['money'] ?></div>
                          <div class="desc mui-ellipsis"><?php echo $val['details'] ?></div>
                      </div>
                  </div>
                  <div class="btnBox">
                      <span><?php echo date('Y-m-d H:i:s', $val['time']) ?></span>
                      <?php if($_SESSION['Member_info'][0]['is_vip'] == 3 && $_SESSION['Member_info'][0]['id'] == $val['shop_id']  && $val['order_type'] == 'waimai'){ ?>
                          <?php switch ($val['state']){case 0:?>
                                <button class="" type="button" name="button" order_id=<?php echo $val['id']; ?>>未支付</button>
                              <?php break; case 1:?>
                              <button class="order_meet" type="button" name="button" order_id=<?php echo $val['id']; ?>>确认接单</button>
                              <?php break; case 5:?>
                               <button class="" type="button" name="button" order_id=<?php echo $val['id']; ?>>已完成</button>
                               <?php break; case 6:?>
                                <button class="" type="button" name="button" order_id=<?php echo $val['id']; ?>>已取消</button>
                              <?php break; default:?>
                              <button class="" type="button" name="button" order_id=<?php echo $val['id']; ?>>配送中</button>
                          <?php } ?>
                      <?php } ?>
                      <button><a href="<?php if($val['order_type'] == 'waimai'){echo 'order_detail';}else{echo 'order_info';} ?>.php?id=<?php echo $val['id'] ?>&type=shop">查看详情</a></button>
                  </div>
              </div>
          </div>
      <?php endforeach; ?>

      <div class="orderList">
        <div class="itemOrder">
          <div class="title">5拍8美食外卖订单</div>
          <div class="itemDetail">
            <div class="itemImg">
              <img src="./images/bg05.jpg" alt="" />
            </div>
            <div class="itemInfo">
              <div class="price">¥999.99</div>
              <div class="desc mui-ellipsis">这是介绍这是介绍</div>
            </div>
          </div>
          <div class="btnBox">
            <span>2019-5-11 11:20:00</span>
            <button>查看详情</button>
          </div>
        </div>
        <div class="itemOrder">
          <div class="title">5拍8美食外卖订单</div>
          <div class="itemDetail">
            <div class="itemImg">
              <img src="./images/bg05.jpg" alt="" />
            </div>
            <div class="itemInfo">
              <div class="price">¥999.99</div>
              <div class="desc mui-ellipsis">这是介绍这是介绍</div>
            </div>
          </div>
          <div class="btnBox">
            <span>2019-5-11 11:20:00</span>
            <button>查看详情</button>
          </div>
        </div>
      </div>

      <div class="orderList">
        <div class="itemOrder">
          <div class="title">5拍8美食外卖订单</div>
          <div class="itemDetail">
            <div class="itemImg">
              <img src="./images/bg05.jpg" alt="" />
            </div>
            <div class="itemInfo">
              <div class="price">¥999.99</div>
              <div class="desc mui-ellipsis">这是介绍这是介绍</div>
            </div>
          </div>
          <div class="btnBox">
            <span>2019-5-11 11:20:00</span>
            <button>查看详情</button>
          </div>
        </div>

        <div class="itemOrder">
          <div class="title">5拍8美食外卖订单</div>
          <div class="itemDetail">
            <div class="itemImg">
              <img src="./images/bg05.jpg" alt="" />
            </div>
            <div class="itemInfo">
              <div class="price">¥999.99</div>
              <div class="desc mui-ellipsis">这是介绍这是介绍</div>
            </div>
          </div>
          <div class="btnBox">
            <span>2019-5-11 11:20:00</span>
            <button>查看详情</button>
          </div>
        </div>

        <div class="itemOrder">
          <div class="title">5拍8美食外卖订单</div>
          <div class="itemDetail">
            <div class="itemImg">
              <img src="./images/bg05.jpg" alt="" />
            </div>
            <div class="itemInfo">
              <div class="price">¥999.99</div>
              <div class="desc mui-ellipsis">这是介绍这是介绍</div>
            </div>
          </div>
          <div class="btnBox">
            <span>2019-5-11 11:20:00</span>
            <button>查看详情</button>
          </div>
        </div>
      </div>
    </div>
    <script src="./js/jquery-2.2.4.min.js"></script>
    <script>
    $(function(){
        $(".order_meet").click(function(){
            var id = $(this).attr('order_id');
            $.ajax({
                url: "order_ajax.php",
                type: "post",
                data: {'id':id},
                dataType: 'JSON',
                success: function(ret) {
                    if(ret.status == 'y'){
                        layer.open({content: ret.info,skin: 'msg',time: 3});
                        window.location.reload();
                    }else if (ret.status == 'n') {
                        layer.open({content: ret.info,skin: 'msg',time: 3});
                    }
                }
            })
        })
    })

      $('.tab').on('click', '.itemTab', function () {
        $(this).addClass('active').siblings().removeClass('active')
        $('.orderList')
          .eq($(this).index())
          .addClass('listAcvtive')
          .siblings()
          .removeClass('listAcvtive')
      })
    </script>
  </body>
</html>
